home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 09, No. 05 (1988-05)(MicroSPARC)(Side A).zip
/
Nibble Volume 09, No. 05 (1988-05)(MicroSPARC)(Side A).po
/
COMMAND.SET.S
< prev
next >
Wrap
Text File
|
1996-12-24
|
13KB
|
518 lines
******************************************
* *
* C O M M A N D . S E T *
* by Jon Hylands *
* a ProDOS utility for *
* adding some useful *
* commands to the BI. *
* *
* Copyright (C) 1988 *
* MicroSPARC, Inc *
* Concord, MA 01742 *
* *
******************************************
* Merlin Pro Assembler, v2.34 *
******************************************
* Zero Page Equates
length = $2F
cswl = $36
pcl = $3A
a1l = $3C
a2l = $3E
a4l = $42
index = $5E
txttab = $67
vartab = $69
strendh = $6E
himem = $73
ptr = $FA
name = $FC
* General System Equates
ibuf = $200
cursor = $7FB
* ProDOS BI Global Page Equates
doscmd = $BE03
extrncmd = $BE06
errout = $BE09
printerr = $BE0C
errcode = $BE0F
vdosio = $BE34
xtrnaddr = $BE50
xcnum = $BE53
pbits = $BE54
spfxbuf = $BEAD
ssnmptr = $BEB5
getbufr = $BEF5
bihimem = $BEFB
* ProDOS System Global Page Equates
devadr32 = $BF26
devlst = $BF32
bitmap = $BF58
level = $BF94
machid = $BF98
pfixptr = $BF9A
* Hardware Page Equates
rd80col = $C01F
spkr = $C030
* Applesoft ROM Equates
linkset = $D4F2
* Monitor ROM Equates
insds2 = $F88C
pcadj = $F953
F8version = $FBB3 $06 if //e or //c
IDbyte = $FBC0 $00 if //c
rdkey = $FD0C
crout = $FD8E
cout = $FDED
move = $FE2C
setv = $FF58 known $60 to set V bit
monitor = $FF69
* ProDOS MLI function call codes
org $2000
* Relocator by Ken Manly
lda #>last-begin+$100
jsr getbufr ask BASIC to reserve space
sta orig remember where it is
sta a1l
sec
sbc #>begin subtract present location
sta relo to see how far program
lda #>last-begin+$100
sta a1l+1 will have to be moved
protect lda a1l Protect program space
jsr setbit from ProDOS by setting
inc a1l bits in the bitmap
dec a1l+1
bne protect
lda himem+1 Make present HIMEM
sta bihimem semi-permanent
lda extrncmd+2 Link CMD into the
sta trynext+3 chain of external
lda extrncmd+1 commands, if any
sta trynext+2
lda orig If CMD cannot
sta extrncmd+2 recognize a command,
lda #0 it will pass control
sta extrncmd+1 to next routine
lda #<begin To start relocation,
sta pcl point program
lda #>begin counter at beginning
sta pcl+1 of program
fixloop ldx #0
jsr insds2 Disassemble an opcode
lda (pcl),y Check opcode
beq fixadr BRK means end of code
ldy length Only 3-byte
cpy #2 instructions need
bne fx1 fixing
lda (pcl),y Only instructions
cmp #>begin referring to addresses
blt fx1 within program
cmp #>last+$100 need fixing
bge fx1
clc Fix by adding RELO
adc relo offset to high byte
sta (pcl),y of address
fx1 jsr pcadj
sta pcl Move program counter
sty pcl+1 to next instruction
jmp fixloop
fxblp clc Add RELO offset to
adc relo hi byte of each
sta atbl,y address in the table
iny Next address
fixadr iny
lda atbl,y 0 means end of
bne fxblp table
ldy #0 Move program to
sty a1l the space reserved
lda #>begin for it, using the
sta a1l+1 monitor MOVE routine
lda #<last
sta a2l
lda #>last
sta a2l+1
sty a4l
lda orig
sta a4l+1
jsr move
ldy #0 Print greeting
bnrlp lda banner0,y
beq bnend
jsr cout
iny
bne bnrlp
bnend rts Return to caller
setbit pha This subroutine protects
and #7 the memory page whose hi
tax address byte is in (A)
pla
lsr a Upper five bits of (A)
lsr a make an index into
lsr a the bit map
tay
lda #0 Lower three bits of (A)
sec choose the bit
setlp ror a to be set -- (X) counts
dex while bit is shifted
bpl setlp from carry bit
ora bitmap,y
sta bitmap,y Set the bit in the bit map
rts
banner0 dfb $8D
asc "COMMAND.SET",8D
asc "A COMMAND UTILITY",8D
asc "COPYRIGHT (C) 1988",8D
asc "MICROSPARC, INC.",8D,8D
asc "COMMANDS : MON, BUZ, IRM, UNW, DIR",8D
asc "IIC-ONLY COMMANDS : CUR, BUF, DBF",8D,8D,00
orig ds 1
relo ds 1
ds \ (org $2200)
********************************
begin cld identify to BI
ldx #0 pointer for command
compr1 lda nametbl,x get low byte of command name address
sta name
lda nametbl+1,x get high byte of command name address
sta name+1
ldy #0
compr lda ibuf,y get byte from command
jsr upshift shift to upper case
cmp (name),y compare it to command name
bne notit get next command name
iny
cpy #3
blt compr check all three letters
bge found
notit inx
inx
cpx cmdnum last command name ?
blt compr1 no, try next one
trynext sec indicate to BI command not found
jmp $0000 (old EXTCMD vector)
found lda nameadr,x trick BI into calling routine directly
sta xtrnaddr
lda nameadr+1,x
sta xtrnaddr+1
lda #0
sta pbits
sta pbits+1
sta xcnum
clc
rts
upshift ora #$80 set high bit just in case
cmp #$FB
bge noshift special characters
cmp #$E1
blt noshift if not lower case
and #$DF clear case bit
noshift rts
********************************
*
* Commands for COMMAND.SET
*
********************************
cur jsr checkIIc IIc?
bne nocur exit with message
lda #$9F (_)
sta cursor (poke 2043,159)
curexit clc
rts
nocur ldx #0
cloop lda IIcmsg,x
beq curexit
jsr cout
inx
bne cloop
mon jsr connect reconnect ProDOS manually
jmp monitor and enter the monitor
********************************
unw cld
lda txttab
ldy txttab+1
sta index
sty index+1
ldy #1
tya
sta (index),Y
unl1 ldy #4
unl2 iny
lda (index),Y
bne unl2
iny
tya
clc
adc index
sta index
bcc unl3
inc index+1
unl3 ldy #1
lda (index),Y
bne unl1
lda #3
clc
adc index
sta vartab
lda index+1
adc #0
sta vartab+1
jsr connect reconnect ProDOS manually
jsr linkset
rts
********************************
connect ldx #3 copy ProDOS I/O vectors back
conloop lda vdosio,x to reconnect it
sta cswl,x
dex
bpl conloop
rts
********************************
checkIIc lda F8version check to see if we have an Apple //c
cmp #6
bne notIIc nope, so exit with zero flag clear
lda IDbyte we know it's a //e or a //c, so now
; see which one and set zero flag
; accordingly
notIIc rts ; routine will exit with zero flag
; set if we have a //c, otherwise
; zero flag is clear
********************************
********************************
buf jsr checkIIc see if we have a //c
bne nobuf nope, so don't try and hook it up
sei ; we do, so disable interrupts
lda #$80
sta $5FA buffer keystrokes without calling
; user's interrupt handler
sta $5FF set pointers for buffer
sta $6FF (where to store next keystroke and
; where the next will be read from)
lda $C0AA port 2 ACIA command register
ora #%00000001 turn it on by setting low bit
sta $C0AA so we can use printer as well
cli ; enable interrupts
clc ; carry must be clear on exit
rts
nobuf ldx #0
nbloop lda IIcmsg,x
beq nbexit
jsr cout
inx
bne nbloop
nbexit clc ; carry must be clear on exit
rts
********************************
dbf jsr checkIIc see if //c once again
bne nobuf nope
clc ; carry must be clear
sei ; yes, so disable interrupts
lda $C0AA get port 2 ACIA command register
and #%11111110 clear low bit to turn it off
sta $C0AA
cli enable interrupts again
rts
********************************
buz jsr buzz2 buzz once
ldy #0
buzz1 dey
bne buzz1 small delay
jsr buzz2 buzz again
rts
buzz2 lda #$10
sta buzztemp
ldx #$14
bl1 bit spkr toggle speaker
bl2 ldy #7
bl3 dey
bne bl3
dex
bne bl2
dec buzztemp
bne bl1
rts
********************************
dir lda #0
sta errcode zero error code
lda rd80col see if 80-column hardware on
bpl noton
lda machid ProDOS machine id
and #%01000000 IIPlus ?
bne noton
ldx #0 index for command
ldy #0 index for buffer
dirl1 lda catalog,x get byte of command
beq dircont if end call command
sta ibuf,y store it in buffer
inx
iny
bne dirl1
dircont jsr doscmd call ProDOS command handler
bcc dirend the carry flag is set if error
jsr printerr BI call to print the right err. message
dirend rts and return
noton ldx #9 index past "CATALOG" to "CAT"
ldy #0
beq dirl1 always
********************************
irm lda $BF98 ; checking for aux memory
and #$30
cmp #$30
bne ramerr ; no aux ram
lda $BF26 ; checking for slot 3, d2
cmp $BF16
beq ramerr
lda $BF27
cmp $BF17
beq ramerr
jmp irm0
ramerr ldx #0
rloop lda ramsg,x
beq rdone
jsr cout
inx
bne rloop
rdone rts
irm0 ldx #0
irmloop lda irmmsg,x get byte to print
beq irmcont end of message?
jsr cout print it
inx
bne irmloop
irmcont jsr rdkey get keypress
jsr upshift must be upper case
cmp #"Y"
bne irmrts if no then return
lda devlst
sta $43 device # is slot 3, drive 2
lda #3
sta $42 command is format
lda himem we need a 512 byte buffer
sta $44 use the BI's G.P. buffer
lda himem+1
sta $45
sta $C080 read RAM bank 2
jsr ramdrv format /RAM
sta $C081 back to ROM
irmrts rts and return
ramdrv jmp (devadr32) call handler
********************************
dfb 0 tells relocator that table follows
atbl = * for relocater
* The first set of addresses, nametbl, points to the command
* names in ASCII.
* The second set, nameadr, points to the actual routines.
* These addresses get relocated.
nametbl da curn,monn,unwn,bufn,dbfn,buzn,dirn,irmn
nameadr da cur,mon,unw,buf,dbf,buz,dir,irm
da $0000 end of relocated code
********************************
* Anything after this point does not get relocated.
cmdnum dfb 16 number of commands*2
curn asc "CUR"
monn asc "MON" please note that you also must
unwn asc "UNW" update the number of commands in
bufn asc "BUF" cmdnum if you add or subtract any.
dbfn asc "DBF"
buzn asc "BUZ"
dirn asc "DIR"
irmn asc "IRM"
buzztemp dfb 0
catalog asc "CATALOG",8D,00
asc "CAT",8D,00
irmmsg dfb $8D
asc "FORMAT /RAM VOLUME ? (Y/N) ",00
IIcmsg dfb $8D
asc "IIC ONLY!",00
ramsg dfb $8D
asc "DEVICE NOT CONNECTED",00
last = *
lst off
lst on
chk ; generate checksum
lst off